package com.xuecheng.system.web.interceptor;

import com.xuecheng.commons.model.vo.AuthInfo;

public class AuthInfoHolder {
    //定义ThreadLocal
    private static ThreadLocal<AuthInfo>t1=new ThreadLocal<>();//info包不一定对
    //存入ThreadLocal
    public static void setAuthInfo(AuthInfo info){
        t1.set(info);
    }
    //从ThreadLocal取出
    public static AuthInfo getAuthInfo(){
        return t1.get();
    }
    //删除ThreadLocal
    public static void remove(){
        t1.remove();
    }
    public static Long getUserId(){
        return t1.get().getUid();
    }
    public static Long getCompanyId(){
        if (t1.get()!=null){
            return t1.get().getCompanyId();
        }else {
            return null;
        }
    }

}
